import { ref, watch } from 'vue'

export default function useSearch (initialValue = '') {
  const keyword = ref(initialValue)
  const search = (value) => {
    keyword.value = value
  }
  const clear = () => {
    keyword.value = ''
  }
  watch(keyword, (value) => {
    console.log('搜索关键词变化', value)
  })
  return {
    keyword,
    search,
    clear
  }
}
